<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<p>登录成功!</p>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script>
    function getLoginStatus() {
        $.ajax({
            type: 'get',
            url: 'login',
            success: function (body) {
                // 得到200 不做任何处理
            },
            error: function (body) {
                // 得到403 强制跳转到 index2.html
                location.assign('index2.html')
            }
        });
    }
    getLoginStatus();
</script>
</body>
</html>